package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@LagouController
@LagouRequestMapping("/demo")
@Security("fmc")
public class DemoController {


    @LagouAutowired
    private IDemoService demoService;


    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @LagouRequestMapping("/query")
    public String query(HttpServletRequest request, HttpServletResponse response,String name) {
        return demoService.get(name);
    }

    @LagouRequestMapping("/zhangsan")
    @Security("zhangsan")
    public String zhangsan(HttpServletRequest request, HttpServletResponse response,String name) {
        String username = request.getParameter("username");
        return "success your name:"+username;
    }

    @LagouRequestMapping("/lisi")
    @Security("lisi")
    public String lisi(HttpServletRequest request, HttpServletResponse response,String name) {
        String username = request.getParameter("username");
        return "success your name:"+username;
    }

    @LagouRequestMapping("/fmc")
    public String fmc(HttpServletRequest request, HttpServletResponse response,String name) {
        String username = request.getParameter("username");
        return "success your name:"+username;
    }

    @LagouRequestMapping("/all")
    @Security("fmc;lisi;zhangsan")
    public String all(HttpServletRequest request, HttpServletResponse response,String name) {
        String username = request.getParameter("username");
        return "success your name:"+username;
    }
}
